<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <p:panel header="PROJETOS" style="width:1500px">
        <h:form id="formProjeto">
            <h:panelGrid columns="9" cellpadding="5">
                Nome:
                <p:inputText size="30" value="#{projetoBean.projeto.nome}"/>
                Categoria:
                <p:selectOneMenu id="categoria" value="#{projetoBean.projeto.categoria}" 
                                 converter="categoriaConverter"  >
                    <f:selectItem itemLabel="-- Selecione --" />
                    <f:selectItems value="#{categoriaBean.categorias}" var="categoria"
                                   itemValue="#{categoria}" itemLabel="#{categoria.nome}"/>

                </p:selectOneMenu> 
                Ano:
                <p:selectOneMenu id="ano">
                    <f:selectItem itemLabel="-- Selecione --" />
                </p:selectOneMenu> 
                Em aberto
                <p:selectBooleanCheckbox>  

                </p:selectBooleanCheckbox>
                <p:commandButton value="Pesquisar" update="gridProjetos" action="#{projetoBean.pesquisar}"/>
            </h:panelGrid>
            <br/><br/>
            <p:dataTable id="gridProjetos"  var="projeto" value="#{projetoBean.projetos}"
                         emptyMessage="Nenhum registro encontrado"
                         paginator="true" rows="10"  
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                         rowKey="#{projeto.id}"
                         selection="#{projetoBean.projConsultado}" selectionMode="single" >
                <p:ajax event="rowSelect" update="botoes"/>
                <p:column headerText="Projeto">
                    <h:outputText value="#{projeto.nome}"/>
                </p:column>
                <p:column headerText="Valor">
                    <h:outputText value="#{projeto.valor}"/>
                </p:column>
                <p:column headerText="Categoria">
                    <h:outputText value="#{projeto.categoria}"/>
                </p:column>
                
                <p:column headerText="Status">
                    <h:outputText value="#{projeto.status}"/>
                </p:column>

                <p:column headerText="Lances"> 
                    <h:outputText value="#{projeto.nrLances}"/>

                </p:column>

                <f:facet name="footer">
                    <h:panelGroup id="botoes">
                        <p:button id="btVisualizar" rendered="#{projetoBean.projConsultado != null}" icon="ui-icon-search" value="Visualizar" outcome="/donoproj/consultarProjeto">
                            <f:param name="projeto" value="#{projetoBean.projConsultado.id}" />
                        </p:button>
                        <p:button id="btLances" rendered="${projetoBean.projConsultado.nrLances != 0}" value="Lances" outcome="/lance/exibirLances" >
                            <f:param name="projeto" value="#{projetoBean.projConsultado.id}" />
                        </p:button>
                    </h:panelGroup>
                </f:facet>

            </p:dataTable>
        </h:form>
    </p:panel>


</html>

